DRBD : Configure
2016/01/27 |
Configure DRBD after installing.
This example is based on the environment like follows. +----------------------+ | +----------------------+ | [ DRBD Server#1 ] |10.0.0.51 | 10.0.0.52| [ DRBD Server#2 ] | | node01.srv.world +----------+----------+ node02.srv.world | | | | | +----------------------+ +----------------------+
It's necessarry the server you'd like to install DRBD has free block-device.
This example shows to configure to use a block-device "/dev/vg_r0/lv_r0".
|
|
[1] | Configure DRBD on both Hosts. |
[root@node01 ~]#
vi /etc/drbd.d/global_common.conf # add follows in the disk section ( detach disk if IO errors happen ) disk {
on-io-error detach;
[root@node01 ~]#
vi /etc/drbd.d/r0.res # create new resource r0 { # DRBD device device /dev/drbd0; # block device disk /dev/vg_r0/lv_r0; meta-disk internal; on node01.srv.world { # IP address:port address 10.0.0.51:7788; } on node02.srv.world { address 10.0.0.52:7788; } } # load module [root@node01 ~]# modprobe drbd [root@node01 ~]# drbd 405309 0 libcrc32c 12644 2 xfs,drbd # create DRBD resource [root@node01 ~]# drbdadm create-md r0 --== Thank you for participating in the global usage survey ==-- The server's response is: you are the 972th user to install this version initializing activity log NOT initializing bitmap Writing meta data... New drbd meta data block successfully created. success[root@node01 ~]# systemctl start drbd
DRBD's startup script waits for the peer node(s) to appear.
- If this node was already a degraded cluster before the
reboot, the timeout is 0 seconds. [degr-wfc-timeout]
- If the peer was available before the reboot, the timeout
is 0 seconds. [wfc-timeout]
(These values are for resource 'r0'; 0 sec -> wait forever)
...
...
To abort waiting enter 'yes' [ 18]:yes
[root@node01 ~]# systemctl enable drbd |
[2] | After configuring on both Hosts, sync data on a Host. |
# current status is "Secondary/Secondary" [root@node01 ~]# cat /proc/drbd version: 8.4.7-1 (api:1/proto:86-101) GIT-hash: 3a6a769340ef93b1ba2792c6461250790795db49 build by root@node01.srv.world, 2016-01-28 14:44:07 0: cs:Connected ro:Secondary/Secondary ds:Inconsistent/Inconsistent C r----- ns:0 nr:0 dw:0 dr:0 al:0 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:f oos:20938076 # get primary role and sync data [root@node01 ~]# drbdadm -- --overwrite-data-of-peer primary r0
# sync starts [root@node01 ~]# cat /proc/drbd version: 8.4.7-1 (api:1/proto:86-101) GIT-hash: 3a6a769340ef93b1ba2792c6461250790795db49 build by root@node01.srv.world, 2016-01-28 14:44:07 0: cs:SyncSource ro:Primary/Secondary ds:UpToDate/Inconsistent C r----- ns:39144 nr:0 dw:0 dr:40056 al:0 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:f oos:20898932 [>....................] sync'ed: 0.2% (20408/20444)M finish: 1:19:58 speed: 4,348 (4,348) K/sec # after syncing, the status turns like follows [root@node01 ~]# cat /proc/drbd version: 8.4.7-1 (api:1/proto:86-101) GIT-hash: 3a6a769340ef93b1ba2792c6461250790795db49 build by root@node01.srv.world, 2016-01-28 14:44:07 0: cs:Connected ro:Primary/Secondary ds:UpToDate/UpToDate C r----- ns:20938076 nr:0 dw:0 dr:20938988 al:0 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:f oos:0 |
[3] | It's OK to configure DRBD, create file system on DRBD device and mount it to use. |
[root@node01 ~]# mkfs.xfs /dev/drbd0 [root@node01 ~]# mkdir /drbd_disk [root@node01 ~]# mount /dev/drbd0 /drbd_disk [root@node01 ~]# df -hT Filesystem Type Size Used Avail Use% Mounted on /dev/mapper/centos-root xfs 27G 1.7G 25G 7% / devtmpfs devtmpfs 2.0G 0 2.0G 0% /dev tmpfs tmpfs 2.0G 0 2.0G 0% /dev/shm tmpfs tmpfs 2.0G 8.3M 2.0G 1% /run tmpfs tmpfs 2.0G 0 2.0G 0% /sys/fs/cgroup /dev/vda1 xfs 497M 206M 292M 42% /boot tmpfs tmpfs 396M 0 396M 0% /run/user/0 /dev/drbd0 xfs 20G 33M 20G 1% /drbd_disk # create a test file [root@node01 ~]# echo 'test file' > /drbd_disk/test.txt [root@node01 ~]# ll /drbd_disk total 4 -rw-r--r-- 1 root root 10 Jan 28 15:32 test.txt |
[4] | To mount DRBD device on the secondary Host, do it like follows. |
########### on primary Host ########### # unmount and get secondary role [root@node01 ~]# umount /drbd_disk [root@node01 ~]# drbdadm secondary r0
########### on secondary Host ########### # get primary role and mount [root@node02 ~]# drbdadm primary r0 [root@node02 ~]# mount /dev/drbd0 /drbd_disk [root@node02 ~]# df -hT Filesystem Type Size Used Avail Use% Mounted on /dev/mapper/centos-root xfs 27G 1.7G 25G 7% / devtmpfs devtmpfs 2.0G 0 2.0G 0% /dev tmpfs tmpfs 2.0G 0 2.0G 0% /dev/shm tmpfs tmpfs 2.0G 8.4M 2.0G 1% /run tmpfs tmpfs 2.0G 0 2.0G 0% /sys/fs/cgroup /dev/vda1 xfs 497M 206M 292M 42% /boot tmpfs tmpfs 396M 0 396M 0% /run/user/0 /dev/drbd0 xfs 20G 33M 20G 1% /drbd_disk[root@node02 ~]# ll /drbd_disk total 4 -rw-r--r-- 1 root root 10 Jan 28 15:32 test.txt |